window.onload = function() {
    var vm = new Vue({
      el: "#layout-d",
      data: {
        addressList: [], // 市列表
        areaList: [], //区列表
        buinsList:[], //商圈列表
        popup: {}, //弹窗对象
        form: {},

      },
      created: function() {
        this.popup = new auiPopup();
      },
      methods: {
        // 获取区县
        getCommonCityItems: function() {
          var _this = this;
          house_server.getCommonCityItems({ cityId: "1" }, function(response) {
            _this.addressList = response.data.params;
            _this.areaList = _this.addressList[0].towns;
            _this.buinsList = _this.areaList[0].tradingareas;
            _this.form.cityId = _this.addressList[0].item_name;
            _this.form.townId = _this.areaList[0].item_name;
            _this.form.tradingAreaId = _this.buinsList[0].item_name;
          });
        },
        // 初始化弹窗
        showPopup: function() {
          this.popup.show(document.getElementById("bottom"));
          this.getCommonCityItems();
        },
        //   提交
        create: function() {
          // for(var key in this.form){
          //     if(this.form[key]){
          //         this.isDisable = true;
          //     }else{
          //         this.isDisable = false;
          //         return;
          //     }
          // }
          var _this = this;
          this.form.type = "2";
          house_server.getDevelopersCreate(this.form, function(res) {
            if (res.code == 200) {
              _this.popup.hide(document.getElementById("created"));
              apiready = function() {
                api.parseTapmode();
              };
              var toast = new auiToast({});
              _this.form = {};
              toast.success({
                title: "提交成功",
                duration: 2000
              });
            }
          });
        }
      },
      ready: function() {
        var _this = this;
        $("#city").on("change", function() {
          var index = $(this)
            .find("option:selected")
            .attr("data-index");
          _this.form.cityId = $(this)
            .find("option:selected")
            .val();
          _this.areaList = _this.addressList[index].towns;
        });
        $("#town").on("change", function() {
            var index = $(this)
              .find("option:selected")
              .attr("data-index");
            _this.form.townId = $(this)
              .find("option:selected")
              .val();
            _this.buinsList = _this.areaList[index].tradingareas;
            _this.form.tradingAreaId = _this.buinsList[0].item_name;
          });
      }
    });
  };
  